#include "RenderScene.h"
#include <Utils.h>
#include <GLM/gtc/type_ptr.hpp>

void renderScene(const std::shared_ptr<CShader>& vShader, bool vIsPatch)
{
	// room cube
	glm::mat4 ModelMatrix = glm::mat4(1.0f);
	ModelMatrix = glm::scale(ModelMatrix, glm::vec3(5.0f));
	vShader->setMat4UniformValue("u_ModelMatrix", glm::value_ptr(ModelMatrix));
	glDisable(GL_CULL_FACE); // note that we disable culling here since we render 'inside' the cube instead of the usual 'outside' which throws off the normal culling methods.
	vShader->setIntUniformValue("u_ReverseNormals", 1);// A small little hack to invert normals when drawing cube from the inside so lighting still works.
	drawCube(vIsPatch);
	vShader->setIntUniformValue("u_ReverseNormals", 0);// and of course disable it
	glEnable(GL_CULL_FACE);
	// cubes
	ModelMatrix = glm::mat4(1.0f);
	ModelMatrix = glm::translate(ModelMatrix, glm::vec3(4.0f, -3.5f, 0.0));
	ModelMatrix = glm::scale(ModelMatrix, glm::vec3(0.5f));
	vShader->setMat4UniformValue("u_ModelMatrix", glm::value_ptr(ModelMatrix));
	drawCube(vIsPatch);
	ModelMatrix = glm::mat4(1.0f);
	ModelMatrix = glm::translate(ModelMatrix, glm::vec3(2.0f, 3.0f, 1.0));
	ModelMatrix = glm::scale(ModelMatrix, glm::vec3(0.75f));
	vShader->setMat4UniformValue("u_ModelMatrix", glm::value_ptr(ModelMatrix));
	drawCube(vIsPatch);
	ModelMatrix = glm::mat4(1.0f);
	ModelMatrix = glm::translate(ModelMatrix, glm::vec3(-3.0f, -1.0f, 0.0));
	ModelMatrix = glm::scale(ModelMatrix, glm::vec3(0.5f));
	vShader->setMat4UniformValue("u_ModelMatrix", glm::value_ptr(ModelMatrix));
	drawCube(vIsPatch);
	ModelMatrix = glm::mat4(1.0f);
	ModelMatrix = glm::translate(ModelMatrix, glm::vec3(-1.5f, 1.0f, 1.5));
	ModelMatrix = glm::scale(ModelMatrix, glm::vec3(0.5f));
	vShader->setMat4UniformValue("u_ModelMatrix", glm::value_ptr(ModelMatrix));
	drawCube(vIsPatch);
	ModelMatrix = glm::mat4(1.0f);
	ModelMatrix = glm::translate(ModelMatrix, glm::vec3(-1.5f, 2.0f, -3.0));
	ModelMatrix = glm::rotate(ModelMatrix, glm::radians(60.0f), glm::normalize(glm::vec3(1.0, 0.0, 1.0)));
	ModelMatrix = glm::scale(ModelMatrix, glm::vec3(0.75f));
	vShader->setMat4UniformValue("u_ModelMatrix", glm::value_ptr(ModelMatrix));
	drawCube(vIsPatch);
}
